<template>
  <view>
      <view class="goods_item">
        <view class="goods_item_left">
          <radio  
          :checked="goods.goods_state" 
          color="#c00000" 
          v-if="showRadio"
          @click="radioChangeHandler"
          ></radio>
          <image :src="goods.goods_small_logo||defaultPic" class="item_pic"></image>
        </view>
        <view class="goods_item_right">
          <view class="goods_item_name">{{goods.goods_name}}</view>
          <view class="goods_info_box">
             <view class="goods_item_price">￥{{goods_price}}</view>
              <uni-number-box 
              :min="1" 
              :modelValue="goods.goods_count" 
              v-if="showNumber"
              @change="bindNumberChange"
              ></uni-number-box>
             <view class="goods_count">
             </view>
          </view>
         
        </view>
      </view>

  </view>
</template>

<script>
  export default {
    props :{
      goods:{
        type:Object,
        default:{}
      },
      showRadio:{
        type:Boolean,
        default:false
      },
      showNumber:{
        type:Boolean,
        default:false
      }
    },
    data(){
      return {
         defaultPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png',
      }
    },
    methods :{
      radioChangeHandler(){
        this.$emit('radioChange',{
          goods_id:this.goods.goods_id,
          goods_state:!this.goods.goods_state,
        })
      },
      bindNumberChange(value){
        this.$emit('NumberChange',{
          goods_id:this.goods.goods_id,
          goods_count:value
        })
      }
    },
    computed:{
      goods_price(){
        return Number(this.goods.goods_price).toFixed(2)
      }
    }
   
}

</script>

<style lang="scss">
      .goods_item {
        width: 750rpx;
        box-sizing: border-box;
        display: flex;
        padding: 10px 5px;
        border-bottom: 1px solid #f0f0f0;
        
        .goods_item_left {
          margin-right: 10px;
          display: flex;
          align-items: center;
          justify-content: space-between;
           .item_pic {
          width: 100px;
          height: 100px;
          display: block;
        } 
       }
       .goods_item_right {
         display: flex;
         flex-direction: column;
         justify-content: space-between;
          flex: 1;
         .goods_item_name {
           font-size: 13px;
           }
          .goods_info_box {
            display: flex;
            align-items: center;
            justify-content: space-between;
           
           .goods_item_price {
             flex: 1;
             font-size: 16px;
             color: #c00000;
         }  
           }
           
        
    }
        
       
  }

</style>
